package br.ufrj.dcc.manifestacoes.util;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TextMiningUtil {

	public static boolean match(ArrayList<String> wordList, String cleanMessage){
		
		Pattern p = Pattern.compile(getRegex(wordList),Pattern.CASE_INSENSITIVE);
		Matcher m = p.matcher(cleanMessage);
		
		return m.find();
	}
	
	public static boolean match(String[] wordList, String cleanMessage){
		
		Pattern p = Pattern.compile(getRegex(wordList),Pattern.CASE_INSENSITIVE);
		Matcher m = p.matcher(cleanMessage);
		
		return m.find();
	}
	
	public static boolean match(String wordList, String cleanMessage){
		
		Pattern p = Pattern.compile(wordList,Pattern.CASE_INSENSITIVE);
		Matcher m = p.matcher(cleanMessage);
		
		return m.find();
	}
	
	public static String getRegex(ArrayList<String> wordList){
        String lstr = wordList.toString();
		return lstr.substring(1, lstr.length()-1).replace(",", " |");
	}
	
	public static String getRegex(String[] wordList){
		String lstr = wordList.toString();
		return lstr.substring(1, lstr.length()-1).replace(",", " |");
	}
	
}
